#import "~/graphql_shared/fragments/author.fragment.graphql"
#import "~/graphql_shared/fragments/label.fragment.graphql"
#import "~/graphql_shared/fragments/page_info.fragment.graphql"

query groupEpics(
  $groupPath: ID!
  $state: EpicState
  $authorUsername: String
  $labelName: [String!]
  $milestoneTitle: String = ""
  $myReactionEmoji: String
  $confidential: Boolean
  $not: NegatedEpicFilterInput
  $or: UnionedEpicFilterInput
  $search: String = ""
  $sortBy: EpicSort
  $firstPageSize: Int
  $lastPageSize: Int
  $prevPageCursor: String = ""
  $nextPageCursor: String = ""
  $isSignedIn: Boolean = false
  $includeDescendantGroups: Boolean = true
) {
  group(fullPath: $groupPath) {
    id
    epics(
      state: $state
      authorUsername: $authorUsername
      labelName: $labelName
      milestoneTitle: $milestoneTitle
      myReactionEmoji: $myReactionEmoji
      confidential: $confidential
      not: $not
      or: $or
      search: $search
      sort: $sortBy
      first: $firstPageSize
      last: $lastPageSize
      after: $nextPageCursor
      before: $prevPageCursor
      includeDescendantGroups: $includeDescendantGroups
    ) {
      nodes {
        id
        iid
        title
        titleHtml
        createdAt
        updatedAt
        startDate
        dueDate
        webUrl
        userDiscussionsCount @include(if: $isSignedIn)
        confidential
        blockingCount
        upvotes
        downvotes
        group {
          id
          fullPath
        }
        author {
          ...Author
        }
        labels {
          nodes {
            ...Label
          }
        }
      }
      pageInfo {
        ...PageInfo
      }
    }
    totalEpics: epics(
      authorUsername: $authorUsername
      labelName: $labelName
      milestoneTitle: $milestoneTitle
      myReactionEmoji: $myReactionEmoji
      confidential: $confidential
      not: $not
      or: $or
      search: $search
      sort: $sortBy
    ) {
      count
    }
    totalOpenedEpics: epics(
      state: opened
      authorUsername: $authorUsername
      labelName: $labelName
      milestoneTitle: $milestoneTitle
      myReactionEmoji: $myReactionEmoji
      confidential: $confidential
      not: $not
      or: $or
      search: $search
      sort: $sortBy
    ) {
      count
    }
    totalClosedEpics: epics(
      state: closed
      authorUsername: $authorUsername
      labelName: $labelName
      milestoneTitle: $milestoneTitle
      myReactionEmoji: $myReactionEmoji
      confidential: $confidential
      not: $not
      or: $or
      search: $search
      sort: $sortBy
    ) {
      count
    }
  }
}
